package com.hgc.ch01.base;

/**
 * Created by 01367627 on 2019/7/5.
 */
public class DaemonThread {

    private static class MyThread extends Thread{

        public MyThread(String name) {
            setName(name);
        }

        @Override
        public void run() {
            while(true){
                System.out.println(getName() + " is Running.");
                try {
                    sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main(String[] args) {
        MyThread myThread = new MyThread("t1");
        myThread.setDaemon(true);
        myThread.start();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("Main Thread Run Over.");
    }

}
